package com.lpf;

import com.lpf.beans.Boss;
import com.lpf.beans.Car;
import com.lpf.beans.Color;
import com.lpf.config.MainConifgOfAutowired;
import com.lpf.ioc.dao.BookDao;
import com.lpf.ioc.service.BookService;
import org.junit.Test;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

public class IOCTest_Autowired {

    @Test
    public void testAutowired() {
        AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext(MainConifgOfAutowired.class);

        BookService bookService = applicationContext.getBean(BookService.class);
        System.out.println("*******" + bookService);

        BookDao bean = applicationContext.getBean(BookDao.class);
        System.out.println("*******" + bean);

        System.out.println("========================================================================");

        Boss boss = applicationContext.getBean(Boss.class);
        System.out.println("*******" + boss);

        Car car = applicationContext.getBean(Car.class);
        System.out.println("*******" + car);

        System.out.println("========================================================================");

        Color color = applicationContext.getBean(Color.class);
        System.out.println("*******" + color);

        System.out.println("*******" + applicationContext);

        applicationContext.close();
    }

}
